package com.zr.daoimpl;

import java.io.Serializable;
import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.zr.dao.ShowFanPriceDao;
import com.zr.model.Cdisstation;
@Repository("shfaprim")
public class ShowFanPriceDaoImpl<T> extends BaseDaoImpl<T> implements ShowFanPriceDao<T>{

	@Override
	public List<Cdisstation> findFanPrice(int page,int rows) {
		
//		StringBuffer sql=new StringBuffer("");
//		sql.append(" SELECT cdisstation.disid,cdisstation.disname,cdisstation.disprice,cdisstation.disscope,");
//		sql.append(" cuser.uname,ccharging.fkgc,ccharging.subkilogramme,ccharging.mtm");
//		sql.append(" FROM cdisstation");
//		sql.append(" INNER JOIN cuser");
//		sql.append(" ON cdisstation.uid=cuser.uid");
//		sql.append(" INNER JOIN ccharging");
		String hql="from Cdisstation";
		Query query=this.getCurrentSession().createQuery(hql);
		//Query query=this.getSessionFactory().openSession().createQuery(hql);
		query.setFirstResult((page-1)*rows);
		query.setMaxResults(rows);
		
		List<Cdisstation>li=query.list();
		
		return li;
	}

	@Override
	public int getcount() {
		String hql="select count(cd.disid) from Cdisstation as cd";
		
		Query query=this.getSessionFactory().openStatelessSession().createQuery(hql);
		int i=((Number)query.uniqueResult()).intValue();
		
		return i;
	}

	

}
